#pragma once

typedef HRESULT (*EVENT_FUNCTION)(LPVOID);
class CHtmlEvents:
    public IDispatch
{
public:
    CHtmlEvents();
    virtual ~CHtmlEvents(void);
    // IUnknown methods
    virtual STDMETHODIMP QueryInterface(REFIID iid,void**ppvObject);
    virtual STDMETHODIMP_(ULONG) AddRef();
    virtual STDMETHODIMP_(ULONG) Release();
    // IDispatch Methods
    HRESULT _stdcall GetTypeInfoCount(unsigned int * pctinfo);
    HRESULT _stdcall GetTypeInfo(unsigned int iTInfo,LCID lcid,ITypeInfo FAR* FAR* ppTInfo);
    HRESULT _stdcall GetIDsOfNames(REFIID riid,OLECHAR FAR* FAR* rgszNames,unsigned int cNames,LCID lcid,DISPID FAR* rgDispId);
    HRESULT _stdcall Invoke(DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS FAR* pDispParams,VARIANT FAR* pVarResult,EXCEPINFO FAR* pExcepInfo,unsigned int FAR* puArgErr);
    //Other Method
    static LPDISPATCH CreateEventObject(EVENT_FUNCTION pFunc, DISPID id, LPVOID lpUserData);
private:
    long _lRef;
    EVENT_FUNCTION _fnEvent;
    DISPID _id;
    LPVOID _pUserData;
};